#include<cstdio>
const double EPS=1e-10;
const int INF=0x7fffffff;
int g[1001][1001],ans=INF,n,vnum=4,doornum=0;
struct point
{
	double x,y;
};
point doors[1000],nodes[1000],t;
struct vector
{
	point start,end;
};
vector line[31];
double multi(point p1,point p2,point p0)
{
	return (p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y);
}
double max(double x,double y){return x>y?x:y;}
double min(double x,double y){return x<y?x:y;}
double abs(double x)
{
	if(x<0)return -x;
	return x;
}
bool iscross(vector v1,vector v2)
{
	if(max(v1.start.x,v1.end.x)>=min(v2.start.x,v2.end.x)&&
	   max(v2.start.x,v2.end.x)>=min(v1.start.x,v1.end.x)&&
	   max(v1.start.y,v1.end.y)>=min(v2.start.y,v2.end.y)&&
	   multi(v2.start,v1.end,v1.start)*multi(v1.end,v2.end,v1.start)>=0&&
	   multi(v1.start,v2.end,v2.start)*multi(v2.end,v1.end,v2.start)>=0)
		return true;
	return false;
}
int main()
{
	double x,y,x1,y1,x2,y2;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
		nodes[i*2-1].x=x1;nodes[i*2-1].y=y1;
		nodes[i*2].x=x2;nodes[i*2].y=y2;
		line[i].start=nodes[i*2-1];line[i].end=nodes[i*2];
	}
	scanf("%lf%lf",&x,&y);
	t.x=x;t.y=y;
	for(int i=1;i<=n*2;i++)
	{
		int tem=0;
		vector v;
		v.start=nodes[i];v.end=t;
		for(int j=1;j<=n;j++)
			if(iscross(v,line[j]))tem++;
		if(tem<ans)ans=tem;
	}
	if(n==0)printf("Number of doors = 1\n");
	else printf("Number of doors = %d\n",ans);
	return 0;
}	
